package com.ld.wms.business.user.controller;

import com.ld.wms.business.user.service.RoleService;
import com.ld.wms.business.user.vo.req.RoleReqVo;
import com.ld.wms.business.user.vo.resp.RoleRespVo;
import com.ld.wms.common.ResultResponse;
import com.ld.wms.common.vo.GenerateListVo;
import com.ld.wms.sysenum.ResultResponseEnum;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@Tag(name = "角色相关接口")
@RestController
public class RoleController {

    @Autowired
    private RoleService roleService;

    @GetMapping("/api/wms/role/getList")
    @Operation(summary = "获取所有角色列表")
    public ResultResponse<GenerateListVo<RoleRespVo>> getList() {
        List<RoleRespVo> list = roleService.getList();
        return ResultResponse.success(new GenerateListVo<>(list));
    }

    @GetMapping("/api/wms/role/getById")
    @Operation(summary = "获取角色详情")
    public ResultResponse<RoleRespVo> getById(@RequestParam Long id) {
        RoleRespVo roleRespVo = roleService.getById(id);
        return ResultResponse.success(roleRespVo);
    }

    @PostMapping("/api/wms/role/add")
    @Operation(summary = "添加角色")
    public ResultResponse<ResultResponseEnum> add(
            @RequestBody RoleReqVo reqVo) {
        roleService.add(reqVo);
        return ResultResponse.success();
    }

    @PostMapping("/api/wms/role/update")
    @Operation(summary = "编辑角色")
    public ResultResponse<ResultResponseEnum> update(
            @RequestBody RoleReqVo reqVo) {
        roleService.update(reqVo);
        return ResultResponse.success();
    }





}
